home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / bbsutils / smb_110a.arj / SMBDEFS.H < prev    next >
C/C++ Source or Header  |  1994-03-25  |  13KB  |  408 lines

  1. /* SMBDEFS.H */
  2.  
  3. #ifndef _SMBDEFS_H
  4. #define _SMBDEFS_H
  5.  
  6. /**********/
  7. /* Macros */
  8. /**********/
  9.  
  10. #define SMB_VERSION         0x0110        /* High byte major, low byte minor */
  11.  
  12.                                         /* Control characters */
  13. #define TAB                 0x09        /* Horizontal tabulation    ^I */
  14. #define LF                    0x0a        /* Line feed                ^J */
  15. #define FF                    0x0c        /* Form feed                ^L */
  16. #define CR                    0x0d        /* Carriage return            ^M */
  17. #define ESC                 0x1b        /* Escape                    ^[ */
  18. #define SP                    0x20        /* Space                       */
  19.  
  20. #define ulong                unsigned long
  21. #define ushort                unsigned short
  22. #define uchar                unsigned char
  23.  
  24. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  25. #define MALLOC  farmalloc
  26. #define REALLOC farrealloc
  27. #define FREE    farfree
  28. #else
  29. #define MALLOC  malloc
  30. #define REALLOC realloc
  31. #define FREE    free
  32. #endif
  33.  
  34. #define smb_close()         { fclose(sid_fp); fclose(shd_fp); fclose(sdt_fp); }
  35.  
  36. #define SDT_BLOCK_LEN        256         /* Size of data blocks */
  37. #define SHD_BLOCK_LEN        256         /* Size of header blocks */
  38.  
  39.                                         /* Time zone macros for when_t.zone */
  40. #define DAYLIGHT            0x8000        /* Daylight savings is active */
  41. #define US_ZONE             0x4000        /* U.S. time zone */
  42. #define WESTERN_ZONE        0x2000        /* Non-standard zone west of UT */
  43. #define EASTERN_ZONE        0x1000        /* Non-standard zone east of UT */
  44.  
  45.                                         /* US Time Zones (standard) */
  46. #define AST                 0x40F0        // Atlantic             (-04:00)
  47. #define EST                 0x412C        // Eastern                (-05:00)
  48. #define CST                 0x4168        // Central                (-06:00)
  49. #define MST                 0x41A4        // Mountain             (-07:00)
  50. #define PST                 0x41E0        // Pacific                (-08:00)
  51. #define YST                 0x421C        // Yukon                (-09:00)
  52. #define HST                 0x4258        // Hawaii/Alaska        (-10:00)
  53. #define BST                 0x4294        // Bering                (-11:00)
  54.  
  55.                                         /* US Time Zones (daylight) */
  56. #define ADT                 0xC0F0        // Atlantic             (-03:00)
  57. #define EDT                 0xC12C        // Eastern                (-04:00)
  58. #define CDT                 0xC168        // Central                (-05:00)
  59. #define MDT                 0xC1A4        // Mountain             (-06:00)
  60. #define PDT                 0xC1E0        // Pacific                (-07:00)
  61. #define YDT                 0xC21C        // Yukon                (-08:00)
  62. #define HDT                 0xC258        // Hawaii/Alaska        (-09:00)
  63. #define BDT                 0xC294        // Bering                (-10:00)
  64.  
  65.                                         /* Non-standard Time Zones */
  66. #define MID                 0x2294        // Midway                (-11:00)
  67. #define VAN                 0x21E0        // Vancouver            (-08:00)
  68. #define EDM                 0x21A4        // Edmonton             (-07:00)
  69. #define WIN                 0x2168        // Winnipeg             (-06:00)
  70. #define BOG                 0x212C        // Bogota                (-05:00)
  71. #define CAR                 0x20F0        // Caracas                (-04:00)
  72. #define RIO                 0x20B4        // Rio de Janeiro        (-03:00)
  73. #define FER                 0x2078        // Fernando de Noronha    (-02:00)
  74. #define AZO                 0x203C        // Azores                (-01:00)
  75. #define LON                 0x1000        // London                (+00:00)
  76. #define BER                 0x103C        // Berlin                (+01:00)
  77. #define ATH                 0x1078        // Athens                (+02:00)
  78. #define MOS                 0x10B4        // Moscow                (+03:00)
  79. #define DUB                 0x10F0        // Dubai                (+04:00)
  80. #define KAB                 0x110E        // Kabul                (+04:30)
  81. #define KAR                 0x112C        // Karachi                (+05:00)
  82. #define BOM                 0x114A        // Bombay                (+05:30)
  83. #define KAT                 0x1159        // Kathmandu            (+05:45)
  84. #define DHA                 0x1168        // Dhaka                (+06:00)
  85. #define BAN                 0x11A4        // Bangkok                (+07:00)
  86. #define HON                 0x11E0        // Hong Kong            (+08:00)
  87. #define TOK                 0x121C        // Tokyo                (+09:00)
  88. #define SYD                 0x1258        // Sydney                (+10:00)
  89. #define NOU                 0x1294        // Noumea                (+11:00)
  90. #define WEL                 0x12D0        // Wellington            (+12:00)
  91.  
  92.                                         /* Valid hfield_t.types */
  93. #define SENDER                0x00
  94. #define SENDERAGENT         0x01
  95. #define SENDERNETTYPE        0x02
  96. #define SENDERNETADDR        0x03
  97. #define SENDEREXT            0x04
  98. #define SENDERPOS            0x05
  99. #define SENDERORG            0x06
  100.  
  101. #define AUTHOR                0x10
  102. #define AUTHORAGENT         0x11
  103. #define AUTHORNETTYPE        0x12
  104. #define AUTHORNETADDR        0x13
  105. #define AUTHOREXT            0x14
  106. #define AUTHORPOS            0x15
  107. #define AUTHORORG            0x16
  108.  
  109. #define REPLYTO             0x20
  110. #define REPLYTOAGENT        0x21
  111. #define REPLYTONETTYPE        0x22
  112. #define REPLYTONETADDR        0x23
  113. #define REPLYTOEXT            0x24
  114. #define REPLYTOPOS            0x25
  115. #define REPLYTOORG            0x26
  116.  
  117. #define RECIPIENT            0x30
  118. #define RECIPIENTAGENT        0x31
  119. #define RECIPIENTNETTYPE    0x32
  120. #define RECIPIENTNETADDR    0x33
  121. #define RECIPIENTEXT        0x34
  122. #define RECIPIENTPOS        0x35
  123. #define RECIPIENTORG        0x36
  124.  
  125. #define FORWARDTO            0x40
  126. #define FORWARDTOAGENT        0x41
  127. #define FORWARDTONETTYPE    0x42
  128. #define FORWARDTONETADDR    0x43
  129. #define FORWARDTOEXT        0x44
  130. #define FORWARDTOPOS        0x45
  131. #define FORWARDTOORG        0x46
  132.  
  133. #define FORWARDED            0x48
  134.  
  135. #define RECEIVEDBY            0x50
  136. #define RECEIVEDBYAGEN        0x51
  137. #define RECEIVEDBYNETTYPE    0x52
  138. #define RECEIVEDBYNETADDR    0x53
  139. #define RECEIVEDBYEXT        0x54
  140. #define RECEIVEDBYPOS        0x55
  141. #define RECEIVEDBYORG        0x56
  142.  
  143. #define RECEIVED            0x58
  144.  
  145. #define SUBJECT             0x60
  146. #define SUMMARY             0x61
  147. #define COMMENT             0x62
  148. #define CARBONCOPY            0x63
  149. #define GROUP                0x64
  150. #define EXPIRATION            0x65
  151. #define PRIORITY            0x66
  152.  
  153. #define FILEATTACH            0x70
  154. #define DESTFILE            0x71
  155. #define FILEATTACHLIST        0x72
  156. #define DESTFILELIST        0x73
  157. #define FILEREQUEST         0x74
  158. #define FILEPASSWORD        0x75
  159. #define FILEREQUESTLIST     0x76
  160. #define FILEPASSWORDLIST    0x77
  161.  
  162. #define IMAGEATTACH         0x80
  163. #define ANIMATTACH            0x81
  164. #define FONTATTACH            0x82
  165. #define SOUNDATTACH         0x83
  166. #define PRESENTATTACH        0x84
  167. #define VIDEOATTACH         0x85
  168. #define APPDATAATTACH        0x86
  169.  
  170. #define IMAGETRIGGER        0x90
  171. #define ANIMTRIGGER         0x91
  172. #define FONTTRIGGER         0x92
  173. #define SOUNDTRIGGER        0x93
  174. #define PRESENTTRIGGER        0x94
  175. #define VIDEOTRIGGER        0x95
  176. #define APPDATATRIGGER        0x96
  177.  
  178. #define FIDOCTRL            0xa0
  179. #define FIDOAREA            0xa1
  180. #define FIDOSEENBY            0xa2
  181. #define FIDOPATH            0xa3
  182. #define FIDOMSGID            0xa4
  183. #define FIDOREPLYID         0xa5
  184. #define FIDOPID             0xa6
  185. #define FIDOFLAGS            0xa7
  186.  
  187. #define RFC822HEADER        0xb0
  188. #define RFC822MSGID         0xb1
  189. #define RFC822REPLYID        0xb2
  190.  
  191. #define UNKNOWN             0xf1
  192. #define UNKNOWNASCII        0xf2
  193. #define UNUSED                0xff
  194.  
  195.                                         /* Valid dfield_t.types */
  196. #define TEXT_BODY            0x00
  197. #define TEXT_SOUL            0x01
  198. #define TEXT_TAIL            0x02
  199. #define TEXT_WING            0x03
  200. #define IMAGEEMBED            0x20
  201. #define ANIMEMBED            0x21
  202. #define FONTEMBED            0x22
  203. #define SOUNDEMBED            0x23
  204. #define PRESENTEMBED        0x24
  205. #define VIDEOEMBED            0x25
  206. #define APPDATAEMBED        0x26
  207. #define UNUSED                0xff
  208.  
  209.  
  210.                                         /* Message attributes */
  211. #define MSG_PRIVATE         (1<<0)
  212. #define MSG_READ            (1<<1)
  213. #define MSG_PERMANENT        (1<<2)
  214. #define MSG_LOCKED            (1<<3)
  215. #define MSG_DELETE            (1<<4)
  216. #define MSG_ANONYMOUS        (1<<5)
  217. #define MSG_KILLREAD        (1<<6)
  218. #define MSG_MODERATED        (1<<7)
  219. #define MSG_VALIDATED        (1<<8)
  220.  
  221.                                         /* Auxillary header attributes */
  222. #define MSG_FILEREQUEST     (1<<0)        // File request
  223. #define MSG_FILEATTACH        (1<<1)        // File(s) attached to Msg
  224. #define MSG_TRUNCFILE        (1<<2)        // Truncate file(s) when sent
  225. #define MSG_KILLFILE        (1<<3)        // Delete file(s) when sent
  226. #define MSG_RECEIPTREQ        (1<<4)        // Return receipt requested
  227. #define MSG_CONFIRMREQ        (1<<5)        // Confirmation receipt requested
  228. #define MSG_NODISP            (1<<6)        // Msg may not be displayed to user
  229.  
  230.                                         /* Message network attributes */
  231. #define MSG_LOCAL            (1<<0)        // Msg created locally
  232. #define MSG_INTRANSIT        (1<<1)        // Msg is in-transit
  233. #define MSG_SENT            (1<<2)        // Sent to remote
  234. #define MSG_KILLSENT        (1<<3)        // Kill when sent
  235. #define MSG_ARCHIVESENT     (1<<4)        // Archive when sent
  236. #define MSG_HOLD            (1<<5)        // Hold for pick-up
  237. #define MSG_CRASH            (1<<6)        // Crash
  238. #define MSG_IMMEDIATE        (1<<7)        // Send Msg now, ignore restrictions
  239. #define MSG_DIRECT            (1<<8)        // Send directly to destination
  240. #define MSG_GATE            (1<<9)        // Send via gateway
  241. #define MSG_ORPHAN            (1<<10)     // Unknown destination
  242. #define MSG_FPU             (1<<11)     // Force pickup
  243. #define MSG_TYPELOCAL        (1<<12)     // Msg is for local use only
  244. #define MSG_TYPEECHO        (1<<13)     // Msg is for conference distribution
  245. #define MSG_TYPENET         (1<<14)     // Msg is direct network mail
  246.  
  247.  
  248. enum {
  249.      NET_NONE
  250.     ,NET_UNKNOWN
  251.     ,NET_FIDO
  252.     ,NET_POSTLINK
  253.     ,NET_QWK
  254.     ,NET_INTERNET
  255.  
  256. /* Add new ones here */
  257.  
  258.     ,NET_TYPES
  259.     };
  260.  
  261. enum {
  262.      AGENT_PERSON
  263.     ,AGENT_PROCESS
  264.  
  265. /* Add new ones here */
  266.  
  267.     ,AGENT_TYPES
  268.     };
  269.  
  270. enum {
  271.      XLAT_NONE              // No translation/End of translation list
  272.     ,XLAT_ENCRYPT           // Encrypted data
  273.     ,XLAT_ESCAPED           // 7-bit ASCII escaping for ctrl and 8-bit data
  274.     ,XLAT_HUFFMAN           // Static and adaptive Huffman coding compression
  275.     ,XLAT_LZW               // Limpel/Ziv/Welch compression
  276.     ,XLAT_MLZ78             // Modified LZ78 compression
  277.     ,XLAT_RLE               // Run length encoding compression
  278.     ,XLAT_IMPLODE           // Implode compression (PkZIP)
  279.     ,XLAT_SHRINK            // Shrink compression (PkZIP)
  280.  
  281. /* Add new ones here */
  282.  
  283.     ,XLAT_TYPES
  284.     };
  285.  
  286.  
  287. /************/
  288. /* Typedefs */
  289. /************/
  290.  
  291. typedef struct {
  292.  
  293.     ulong    time;            // Local time (unix format)
  294.     short    zone;            // Time zone
  295.  
  296.     } when_t;
  297.  
  298. typedef struct {
  299.  
  300.     ushort    to;             // 16-bit CRC of recipient name (lower case)
  301.     ushort    from;            // 16-bit CRC of sender name (lower case)
  302.     ushort    subj;            // 16-bit CRC of subject (lower case, w/o RE:)
  303.     ushort    attr;            // attributes (read, permanent, etc.)
  304.     ulong    offset;         // offset into header file
  305.     ulong    number;         // number of message (1 based)
  306.     ulong    time;            // time/date message was imported/posted
  307.  
  308.     } idxrec_t;
  309.  
  310. typedef struct {
  311.  
  312.     uchar   id[4];          // text or binary unique hdr ID
  313.     ushort  version;        // version number (initially 100h for 1.00)
  314.     ushort  length;         // length including this struct
  315.  
  316.     } smbhdr_t;
  317.  
  318. typedef struct {
  319.  
  320.     ulong    last_msg;        // last message number
  321.     ulong    total_msgs;     // total messages
  322.     ulong    header_offset;    // byte offset to first header record
  323.     ulong    max_crcs;        // Maximum number of CRCs to keep in history
  324.     ulong   max_msgs;       // Maximum number of message to keep in sub
  325.     ushort  max_age;        // Maximum age of message to keep in sub (in days)
  326.     ushort    reserved;        // Reserved for future use
  327.  
  328.     } smbstatus_t;
  329.  
  330. typedef struct {
  331.  
  332.     uchar    id[4];            // SHD<^Z>
  333.     ushort  type;           // Message type (normally 0)
  334.     ushort  version;        // Version of type (initially 100h for 1.00)
  335.     ushort  length;         // Total length of fixed record + all fields
  336.     ushort    attr;            // Attributes (bit field) (duped in SID)
  337.     ulong    auxattr;        // Auxillary attributes (bit field)
  338.     ulong   netattr;        // Network attributes
  339.     when_t    when_written;    // Time message was written (unix format)
  340.     when_t    when_imported;    // Time message was imported
  341.     ulong   number;         // Message number
  342.     ulong   thread_orig;    // Original message number in thread
  343.     ulong   thread_next;    // Next message in thread
  344.     ulong   thread_first;   // First reply to this message
  345.     uchar    reserved[16];    // Reserved for future use
  346.     ulong   offset;         // Offset for buffer into data file (0 or mod 256)
  347.     ushort    total_dfields;    // Total number of data fields
  348.  
  349.     } msghdr_t;
  350.  
  351. typedef struct {
  352.  
  353.     ushort    type;            // Type of data field
  354.     ulong   offset;         // Offset into buffer 
  355.     ulong   length;         // Length of data field
  356.  
  357.     } dfield_t;
  358.  
  359. typedef struct {
  360.  
  361.     ushort    type;
  362.     ushort    length;         // Length of buffer
  363.  
  364.     } hfield_t;
  365.  
  366. typedef struct {
  367.  
  368.     ushort    zone;
  369.     ushort    net;
  370.     ushort    node;
  371.     ushort    point;
  372.  
  373.     } fidoaddr_t;
  374.  
  375. typedef struct {
  376.  
  377.     ushort  type;
  378.     void    *addr;
  379.  
  380.     } net_t;
  381.  
  382. typedef struct {
  383.  
  384.     idxrec_t    idx;            // Index
  385.     msghdr_t    hdr;            // Header record (fixed portion)
  386.     uchar        *to,            // To name
  387.                 *to_ext,        // To extension
  388.                 *from,            // From name
  389.                 *from_ext,        // From extension
  390.                 *replyto,        // Reply-to name
  391.                 *replyto_ext,    // Reply-to extension */
  392.                 *subj;            // Subject
  393.     ushort        to_agent,        // Type of agent message is to
  394.                 from_agent,     // Type of agent message is from
  395.                 replyto_agent;    // Type of agent replies should be sent to
  396.     net_t        to_net,         // Destination network type and address
  397.                 from_net,       // Origin network address
  398.                 replyto_net;    // Network type and address for replies
  399.     ushort        total_hfields;    // Total number of header fields
  400.     hfield_t    *hfield;        // Header fields (fixed length portion)
  401.     void        **hfield_dat;    // Header fields (variable length portion)
  402.     dfield_t    *dfield;        // Data fields (fixed length portion)
  403.     ulong        offset;         // Offset (number of records) into index
  404.  
  405.     } smbmsg_t;
  406.  
  407. #endif /* Don't add anything after this #endif statement */
  408.